#ifndef _WEBCACHE_H_
#define _WEBCACHE_H_

#include "commonstruct.h"
#include "string.h"
#include <stdlib.h>

#include "dataarray.h"

#include <math.h>
#include "mylist.h"
#include <direct.h>
#include <winsock2.h>

class CWebCache
{
public:
	CWebCache();
	virtual ~CWebCache();
public:
	int Start();
	bool Verify(MYSOCKET &mysocket,const char *pSerial);
    bool GetWebSite(MYSOCKET &mysocket);
private:
    USERINFO m_userinfo;

	char m_szLibVer[16];
	static CWebCache *m_pThis;

private:
	bool ConnectServer(MYSOCKET &mysocket,int nRcvTime,int nSndTime);
	bool SendData(int nCommand,int nRecordCount,char *pData,int nLen,MYSOCKET &mysocket);
	bool SendVerify(MYSOCKET &mysocket,PVERIFY pVerify);

    static UINT WINAPI ThreadCltData(LPVOID lpParam);
	bool SendCacheFile(MYSOCKET &mysocket,char *pUserCode);
	void InitVerify(VERIFY &verify,const char *pSerial);

	void GetMacAddress(char *pMac);
	void EnCrypt(LPSTR buffer,int len);
	void DeCrypt(char* szBuffer,int nBYTELen);
	void StrToAr(char *pStr,CDataArray &ar);
	void DeleteAr(CDataArray &ar);
	bool GetHostIP(char * host,char *pIP);
};


#endif
